<template>
  <div class="l-rblock l-form-viewer" style="padding:8px;">
    <el-form :model="formData" :rules="rules" size="mini" labelPosition="right" labelWidth="120px" ref="form">
      <div class="l-auto-window only-tabs">
        <el-tabs v-model="activeName" type="card">
          <el-tab-pane class="l-tabs-container" :label="$t('主表信息')" name="tab0">
            <l-custom-form ref="CustomForm" :disabled="disabled" :columns="columns" :span="24"></l-custom-form>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-form>
  </div>
</template>
<script>

export default {
  props: {
    disabled: {
      type: Boolean,
      default: false,
    },
    config: Object
  },

  data() {
    return {
      activeName: 'tab0',

      // 表单信息
      formData: this.config.formData,
      rules: this.config.rules,
      columns: this.config.formColmuns,

    };
  },
  methods: {

    // 重置表单
    resetForm() {
      this.$formClear(this.$refs.form)
      this.activeName = 'tab0'

    },
    // 校验表单
    async validateForm() {
      if (!await this.$formValidateWraper(this.$refs.form)) {
        return false
      }

      return true
    },

    // 获取表单数据
    getForm() {
      return this.formData
    },


    async saveForm() {
      const postData = this.getForm()
      // 新增
      const api = window.$crud("srds/project/info");
      return await this.$awaitWraper(api.add(postData))

    },
  }
}
</script>